/*
 * @Author: doing
 * @Date: 2023-08-23 18:58:30
 * @LastEditors: git config user.name && git config user.email
 * @LastEditTime: 2023-08-23 19:10:13
 * @FilePath: \center\src\utils\request.js
 * @Description: 
 * 封装request
 * Copyright (c) 2023 by 1540265624@qq.com, All Rights Reserved. 
 */
import axios from 'axios'

const service = axios.create({
  // .env.development 和 .env.productiont
  baseURL: import.meta.env.VITE_PROXY_API, // url = base url + request url
  timeout: 10000 // request timeout
})

// 请求拦截器
service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

// 响应拦截器
service.interceptors.response.use(
  response => { 
    // 正常响应
    const res = response.data
    return res
  },
  error => {
    // 响应异常
    return Promise.reject(error)
  }
)

export default service
